﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ClassLibrary.Entity;
using ClassLibrary.Data;
using System.Collections.Generic;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session[Global.SESSION_LOGGED_USER] == null)
            {
                hyThoat.Visible = false;
                hyLogin.Visible = true;
                lnkRegister.Visible = true;
                hyName.Visible = false;
            }
            else
            {
                hyThoat.Visible = true;
                hyLogin.Visible = false;
                lnkRegister.Visible = false;
                hyName.Visible = true;
                hyName.Text = ((TblCustomers)Session[Global.SESSION_LOGGED_USER]).FName + ((TblCustomers)Session[Global.SESSION_LOGGED_USER]).LName;
                
            }
        }
        UpdateShoppingCartSession();

    }
    protected void hyThoat_Click(object sender, EventArgs e)
    {
        Session[Global.SESSION_LOGGED_USER] = null;
        Response.Redirect("Index.aspx");
    }
    public void UpdateShoppingCartSession()
    {
        if (HttpContext.Current.Session[Global.SESSION_CART] != null)
        {
            List<TblBookingDetail> cartItems = (List<TblBookingDetail>)HttpContext.Current.Session[Global.SESSION_CART];

            int iQuantity = 0;
            double dAmount = 0;
            foreach (TblBookingDetail order in cartItems)
            {
                iQuantity += order.Quantity;
                //dAmount +=  order.TotalAmount;
                dAmount += Convert.ToDouble(order.Quantity * order.Price);
            }
            lbsoluong.Text = "Successful!";
            //lblAmout.Text = dAmount.ToString("c");
        }
    }

}
